// $ANTLR 3.1.1 /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g 2009-01-14 21:12:07

import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

public class simple_expressionParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "NEWLINE", "INT", "WS", "'+'", "'-'", "'*'", "'/'", "'('", "')'"
    };
    public static final int T__7=7;
    public static final int T__12=12;
    public static final int INT=5;
    public static final int T__8=8;
    public static final int WS=6;
    public static final int EOF=-1;
    public static final int T__10=10;
    public static final int T__9=9;
    public static final int T__11=11;
    public static final int NEWLINE=4;

    // delegates
    // delegators


        public simple_expressionParser(TokenStream input) {
            this(input, new RecognizerSharedState());
        }
        public simple_expressionParser(TokenStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        

    public String[] getTokenNames() { return simple_expressionParser.tokenNames; }
    public String getGrammarFileName() { return "/Users/andrewpangborn/Code/antlr_presentation/simple_expression.g"; }



    // $ANTLR start "prog"
    // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:3:1: prog : ( stat )+ ;
    public final void prog() throws RecognitionException {
        try {
            // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:3:5: ( ( stat )+ )
            // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:3:9: ( stat )+
            {
            // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:3:9: ( stat )+
            int cnt1=0;
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( ((LA1_0>=NEWLINE && LA1_0<=INT)||LA1_0==11) ) {
                    alt1=1;
                }


                switch (alt1) {
            	case 1 :
            	    // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:3:9: stat
            	    {
            	    pushFollow(FOLLOW_stat_in_prog11);
            	    stat();

            	    state._fsp--;


            	    }
            	    break;

            	default :
            	    if ( cnt1 >= 1 ) break loop1;
                        EarlyExitException eee =
                            new EarlyExitException(1, input);
                        throw eee;
                }
                cnt1++;
            } while (true);


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "prog"


    // $ANTLR start "stat"
    // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:5:1: stat : ( expr NEWLINE | NEWLINE );
    public final void stat() throws RecognitionException {
        try {
            // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:5:5: ( expr NEWLINE | NEWLINE )
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( (LA2_0==INT||LA2_0==11) ) {
                alt2=1;
            }
            else if ( (LA2_0==NEWLINE) ) {
                alt2=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 2, 0, input);

                throw nvae;
            }
            switch (alt2) {
                case 1 :
                    // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:5:9: expr NEWLINE
                    {
                    pushFollow(FOLLOW_expr_in_stat38);
                    expr();

                    state._fsp--;

                    match(input,NEWLINE,FOLLOW_NEWLINE_in_stat40); 

                    }
                    break;
                case 2 :
                    // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:6:9: NEWLINE
                    {
                    match(input,NEWLINE,FOLLOW_NEWLINE_in_stat50); 

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "stat"


    // $ANTLR start "expr"
    // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:9:1: expr : multExpr ( '+' multExpr | '-' multExpr )* ;
    public final void expr() throws RecognitionException {
        try {
            // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:9:6: ( multExpr ( '+' multExpr | '-' multExpr )* )
            // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:9:10: multExpr ( '+' multExpr | '-' multExpr )*
            {
            pushFollow(FOLLOW_multExpr_in_expr65);
            multExpr();

            state._fsp--;

            // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:9:19: ( '+' multExpr | '-' multExpr )*
            loop3:
            do {
                int alt3=3;
                int LA3_0 = input.LA(1);

                if ( (LA3_0==7) ) {
                    alt3=1;
                }
                else if ( (LA3_0==8) ) {
                    alt3=2;
                }


                switch (alt3) {
            	case 1 :
            	    // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:9:21: '+' multExpr
            	    {
            	    match(input,7,FOLLOW_7_in_expr69); 
            	    pushFollow(FOLLOW_multExpr_in_expr71);
            	    multExpr();

            	    state._fsp--;


            	    }
            	    break;
            	case 2 :
            	    // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:9:36: '-' multExpr
            	    {
            	    match(input,8,FOLLOW_8_in_expr75); 
            	    pushFollow(FOLLOW_multExpr_in_expr77);
            	    multExpr();

            	    state._fsp--;


            	    }
            	    break;

            	default :
            	    break loop3;
                }
            } while (true);


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "expr"


    // $ANTLR start "multExpr"
    // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:11:1: multExpr : atom ( '*' atom | '/' atom )* ;
    public final void multExpr() throws RecognitionException {
        try {
            // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:11:10: ( atom ( '*' atom | '/' atom )* )
            // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:11:13: atom ( '*' atom | '/' atom )*
            {
            pushFollow(FOLLOW_atom_in_multExpr90);
            atom();

            state._fsp--;

            // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:11:18: ( '*' atom | '/' atom )*
            loop4:
            do {
                int alt4=3;
                int LA4_0 = input.LA(1);

                if ( (LA4_0==9) ) {
                    alt4=1;
                }
                else if ( (LA4_0==10) ) {
                    alt4=2;
                }


                switch (alt4) {
            	case 1 :
            	    // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:11:19: '*' atom
            	    {
            	    match(input,9,FOLLOW_9_in_multExpr93); 
            	    pushFollow(FOLLOW_atom_in_multExpr95);
            	    atom();

            	    state._fsp--;


            	    }
            	    break;
            	case 2 :
            	    // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:11:30: '/' atom
            	    {
            	    match(input,10,FOLLOW_10_in_multExpr99); 
            	    pushFollow(FOLLOW_atom_in_multExpr101);
            	    atom();

            	    state._fsp--;


            	    }
            	    break;

            	default :
            	    break loop4;
                }
            } while (true);


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "multExpr"


    // $ANTLR start "atom"
    // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:14:1: atom : ( INT | '(' expr ')' );
    public final void atom() throws RecognitionException {
        try {
            // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:14:6: ( INT | '(' expr ')' )
            int alt5=2;
            int LA5_0 = input.LA(1);

            if ( (LA5_0==INT) ) {
                alt5=1;
            }
            else if ( (LA5_0==11) ) {
                alt5=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 5, 0, input);

                throw nvae;
            }
            switch (alt5) {
                case 1 :
                    // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:14:9: INT
                    {
                    match(input,INT,FOLLOW_INT_in_atom118); 

                    }
                    break;
                case 2 :
                    // /Users/andrewpangborn/Code/antlr_presentation/simple_expression.g:15:9: '(' expr ')'
                    {
                    match(input,11,FOLLOW_11_in_atom128); 
                    pushFollow(FOLLOW_expr_in_atom130);
                    expr();

                    state._fsp--;

                    match(input,12,FOLLOW_12_in_atom132); 

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "atom"

    // Delegated rules


 

    public static final BitSet FOLLOW_stat_in_prog11 = new BitSet(new long[]{0x0000000000000832L});
    public static final BitSet FOLLOW_expr_in_stat38 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_NEWLINE_in_stat40 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_NEWLINE_in_stat50 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_multExpr_in_expr65 = new BitSet(new long[]{0x0000000000000182L});
    public static final BitSet FOLLOW_7_in_expr69 = new BitSet(new long[]{0x0000000000000820L});
    public static final BitSet FOLLOW_multExpr_in_expr71 = new BitSet(new long[]{0x0000000000000182L});
    public static final BitSet FOLLOW_8_in_expr75 = new BitSet(new long[]{0x0000000000000820L});
    public static final BitSet FOLLOW_multExpr_in_expr77 = new BitSet(new long[]{0x0000000000000182L});
    public static final BitSet FOLLOW_atom_in_multExpr90 = new BitSet(new long[]{0x0000000000000602L});
    public static final BitSet FOLLOW_9_in_multExpr93 = new BitSet(new long[]{0x0000000000000820L});
    public static final BitSet FOLLOW_atom_in_multExpr95 = new BitSet(new long[]{0x0000000000000602L});
    public static final BitSet FOLLOW_10_in_multExpr99 = new BitSet(new long[]{0x0000000000000820L});
    public static final BitSet FOLLOW_atom_in_multExpr101 = new BitSet(new long[]{0x0000000000000602L});
    public static final BitSet FOLLOW_INT_in_atom118 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_11_in_atom128 = new BitSet(new long[]{0x0000000000000820L});
    public static final BitSet FOLLOW_expr_in_atom130 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_12_in_atom132 = new BitSet(new long[]{0x0000000000000002L});

}